/////////////////////////////////////////////////////////////////////////////
// tray_icon.h : header file
//

#ifndef _INCLUDED_TRAYICON_H_
#define _INCLUDED_TRAYICON_H_

/////////////////////////////////////////////////////////////////////////////
// tray_icon window

#include "TaTaMain.h"

class tray_msg;

class tray_icon : public CObject
{
// Construction/destruction
public:
	tray_icon();
	tray_icon(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID);
	virtual ~tray_icon();

// Operations
public:
	BOOL Enabled() { return b_enabled_; }
	BOOL Visible() { return !b_hidden_; }

	//Create the tray icon
	int Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID);

	//Change or retrieve the Tooltip text
	BOOL    set_tooltip_text(LPCTSTR text);
	BOOL    set_tooltip_text(UINT nID);
	CString get_tooltip_text() const;

	//Change or retrieve the icon displayed
	BOOL  set_icon(HICON icon);
	BOOL  set_icon(LPCTSTR icon_name);
	BOOL  set_icon(UINT id_resource);
	BOOL  set_standard_icon(LPCTSTR icon_name);
	BOOL  set_standard_icon(UINT id_resource);
	BOOL  set_menu(UINT uID);
	HICON get_icon() const;
	void  hide_icon();
	void  show_icon();
	void  remove_icon();
	void  move_to_right();
	
	//Change or retrieve the window to send notification messages to
	BOOL  set_notify_caption_wnd(CWnd* pNotifyWnd);
	void set_tray_msg(tray_msg *ptray);
	CWnd* get_notify_caption_wnd() const;

	//Default handler for tray notification message
	virtual LRESULT on_tray_notification(WPARAM uID, LPARAM lEvent);


	static HWND get_tray_notify_hwnd();

	BOOL FindOutPositionOfIconDirectly(CRect& a_rcIcon);
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(tray_icon)
	//}}AFX_VIRTUAL

// Implementation

public:
	BOOL is_track_mouse_;
	POINT pt_mouse_;

protected:
	
	static BOOL CALLBACK FindTrayWnd(HWND hwnd, LPARAM lParam);
	static BOOL CALLBACK FindToolBarInTrayWnd(HWND hwnd, LPARAM lParam);
	static CRect GetTrayWndRect();
	BOOL			b_enabled_;	// does O/S support tray icon?
	BOOL			b_hidden_;	// Has the icon been hidden?
	NOTIFYICONDATA	notify_icon_data_;
	UINT	menu_id_;
	tray_msg *tray_msg_;
	
	DECLARE_DYNAMIC(tray_icon)
};


#endif

/////////////////////////////////////////////////////////////////////////////
